package br.com.async.application.impl;

import java.util.Calendar;
import java.util.List;
import java.util.Set;

import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import br.com.async.application.ReserveApplication;
import br.com.async.domain.reserve.Reserve;
import br.com.async.domain.reserve.ReserveRepository;
import br.com.async.domain.reserve.Shift;
import br.com.async.domain.reserve.Time;

@Transactional(propagation = Propagation.REQUIRED)
public class ReserveApplicationImpl implements ReserveApplication {

	private ReserveRepository reserveRepository;

	public ReserveApplicationImpl(ReserveRepository reserveRepository) {
		super();
		this.reserveRepository = reserveRepository;
	}

	@Override
	public void persist(Reserve entity) {
		reserveRepository.persist(entity);
	}

	@Override
	public void update(Reserve entity) {
		reserveRepository.update(entity);
	}

	@Override
	public List<Reserve> list() {
		return reserveRepository.list();
	}

//	@Override
//	public void disable(Reserve entity) {
//		reserveRepository.disable(entity);
//	}
	
	@Override
	public void disable(Reserve entity) {
		reserveRepository.disable(entity);
	}

	@Override
	public Reserve findByCode(Integer code) {
		return reserveRepository.findByCode(code);
	}
	
	public List<Reserve> findReserveByCriterions(Integer roomCode, Calendar date, Shift shift){
		return reserveRepository.findReserveByCriterions(roomCode, date, shift);
	}
	
	public Reserve findUniqueReserveByCriterions(Integer roomCode, Calendar date, Shift shift){
		return reserveRepository.findUniqueReserveByCriterions(roomCode, date, shift);
	}
	
	public List<Reserve> findReserveByCriterions(String roomName, Calendar date, Shift shift){
		return reserveRepository.findReserveByCriterions(roomName, date, shift);
	}
	

	@Override
	public List<Reserve> findReserveForRomAndDate(String room, Calendar date) {
		return reserveRepository.findReserveForRomAndDate(room, date);
	}

	@Override
	public List<Time> findTimeFreeFromReserve(Reserve reserve) {
		return reserveRepository.findTimeFreeFromReserve(reserve);
	}

	@Override
	public List<Shift> verifyShiftFree(String room, Calendar date) {
		return null;
	}

	@Override
	public List<Reserve> findReserveByResponsible(Integer respCode) {
		
		return reserveRepository.findReserveByResponsible(respCode);
	}
	
	public List<Reserve> findReserveByCriterions(
			Calendar date){
		return reserveRepository.findReserveByCriterions(date);
	}

	@Override
	public List<Reserve> findReserveByCriterions(Integer respCode, Calendar date) {
		return reserveRepository.findReserveByCriterions(respCode, date);
	}
	
	

}
